#include <QtGui/QApplication>
#include "gui/mainwindow.h"
#include <QTextCodec>
#include <QTranslator>
#include <QLocale>
#include <QMessageBox>

class aeApplication : public QApplication
{
public:
	aeApplication (int &argc, char *argv[])
		: QApplication(argc, argv)
	{
	}

	bool notify (QObject *receiver, QEvent *e)
	{
		try
		{
			QApplication::notify(receiver, e);
		}

		catch (...)
		{
			QMessageBox::critical(NULL, "ERROR!", "Unexpected error.\nIt's really, really strange.");
		}
	}
};

int main(int argc, char *argv[])
{
	QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
	QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
	QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
	aeApplication a(argc, argv);

	QTranslator myTranslator;
	myTranslator.load("activityedit_"+QLocale::system().name());
	a.installTranslator(&myTranslator);

	MainWindow w;
    w.show();

	return a.exec();
}

